<template>
  <a-modal
    :visible="true"
    title="接收详情"
    :footer="null"
    width="600px"
    class="receive-detail-model"
    @cancel="dismiss"
  >
    <template #closeIcon>
      <svg-icon icon-class="icon_search_delete" class-name="icon-search-delete"></svg-icon>
    </template>
    <!-- 发件信息 -->
    <div class="info-top">
      <div>
        <span class="title">发件人：</span>
        <span class="content">赵乐乐</span>
      </div>
      <div>
        <span class="title">发件时间：</span>
        <span class="content">2023-04-20</span>
      </div>
    </div>
    <!-- 表格内容 -->
    <div class="info-content">
      <a-table
        :columns="columns"
        :data-source="dataSource"
        :show-header="false"
        bordered
        :pagination="false"
        :scroll="{ y: 504 }"
      >
        <template #bodyCell="{ text, column, record }">
          <div v-if="column.dataIndex === 'content' && record.key === '8'" class="file-info">
            <div v-for="i in 3" :key="i" class="file-item">
              <div @click="previewFile(i)"><span>基本信息填报表.xlsx</span></div>
              <div @click="downloadFile(i)"
                ><svg-icon icon-class="btn_icon_download" class-name="btn-icon-download"></svg-icon
              ></div>
            </div>
          </div>
          <div v-else class="cell-content">{{ text ? text : '--' }}</div>
        </template>
      </a-table>
    </div>
    <!-- 底部按钮 -->
    <div class="info-footer">
      <a-button class="cancel-btn" @click="dismiss">取消</a-button>
      <a-button type="primary" ghost @click="receiveAndCheck">签收并登记</a-button>
      <a-button type="primary" @click="receiveDoc">直接签收</a-button>
    </div>
  </a-modal>
</template>
<script setup>
import { defineProps, defineEmits, ref } from 'vue';
const props = defineProps({
  recordId: {
    type: Number,
    default: 0
  }
});
const columns = [
  {
    title: 'title',
    dataIndex: 'title',
    width: '102px'
  },
  {
    title: 'content',
    dataIndex: 'content',
    width: '449px'
  }
];
let titleArr = [
  '公文标题',
  '文号',
  '紧急程度',
  '密级',
  '发文单位',
  '主送单位',
  '抄送单位',
  '内容',
  '附件'
];
const dataSource = ref([]);
for (let i = 0; i < titleArr.length; i++) {
  dataSource.value.push({
    key: i.toString(),
    title: titleArr[i],
    content: '内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容'
  });
}
const emit = defineEmits([
  'receiveDetailDismiss',
  'doReceiveAndCheck',
  'doReceiveDoc',
  'doDownloadFile',
  'doPreviewFile'
]);

function receiveAndCheck() {
  emit('doReceiveAndCheck', props.recordId);
}
function receiveDoc() {
  emit('doReceiveDoc', props.recordId);
}
function downloadFile(fileId) {
  emit('doDownloadFile', 'fileId' + fileId);
}
function previewFile(fileId) {
  emit('doPreviewFile', 'fileId' + fileId);
}

function dismiss() {
  // console.log('dismiss');
  emit('receiveDetailDismiss');
}
</script>
<style lang="less">
.receive-detail-model {
  top: 50px;
  .icon-search-delete {
    margin: 23px auto 0;
    width: 20px;
    height: 20px;
  }

  .ant-modal-content {
    width: 600px;
    border-radius: 6px;
    .ant-modal-header {
      display: flex;
      align-items: center;
      height: 66px;
      border-radius: 6px;
      border: 0;
      .ant-modal-title {
        font-size: 18px;
        font-family: Source Han Sans CN, Source Han Sans CN-Medium !important;
        font-weight: 500;
        color: rgba(0, 0, 0, 0.8);
      }
    }
    .ant-modal-body {
      padding: 0;
      .info-top {
        margin-left: 24px;
        padding: 16px;
        width: 552px;
        height: 88px;
        background: #f5f6f7;
        border-radius: 4px;
        div {
          height: 22px;
          margin-bottom: 12px;
          font-size: 14px;
          font-family: Source Han Sans CN, Source Han Sans CN-Regular;
          color: rgba(0, 0, 0, 0.8);
          line-height: 22px;
          .title {
            display: inline-block;
            width: 70px;
            text-align: right;
            color: rgba(0, 0, 0, 0.6);
          }
        }
      }
      .info-content {
        margin-left: 24px;
        margin-top: 16px;
        width: 552px;
        height: 506px;
        border-top: 0.5px solid rgba(186, 191, 197, 0.4);
        // overflow-y: scroll;
        .ant-table-cell {
          padding: 5px 16px;

          .file-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 44px;
            span {
              font-size: 14px;
              font-family: Source Han Sans CN, Source Han Sans CN-Regular;
              color: #3296fa;
              line-height: 22px;
              cursor: pointer;
            }
            .btn-icon-download {
              width: 16px;
              height: 16px;
              color: #8e959f;
              cursor: pointer;
            }
          }
          .cell-content {
            display: flex;
            align-items: center;
            min-height: 44px;
            font-size: 14px;
            line-height: 22px;
            color: rgba(0, 0, 0, 0.8);
            font-family: Source Han Sans CN, Source Han Sans CN-Regular;
            vertical-align: middle;
          }
        }
      }
      .ant-table-tbody > tr.ant-table-row:hover > td {
        background: none !important;
      }
      .info-footer {
        margin-left: 24px;
        display: flex;
        justify-content: flex-end;
        margin-top: 16px;
        width: 552px;
        height: 56px;
        font-size: 14px;
        font-family: Source Han Sans CN, Source Han Sans CN-Regular;
        .ant-btn {
          margin-left: 16px;
          border-radius: 4px;
        }

        .cancel-btn {
          color: rgba(0, 0, 0, 0.4);
          border: 1px solid rgba(186, 191, 197, 0.4);
        }
      }
      ::-webkit-scrollbar {
        display: none;
      }
    }
  }
}
</style>
